namespace Maple.Branch.Identity.DefinitionProviders
{
    using Consts;
    using Localizations;
    using Volo.Abp.Localization;
    using Volo.Abp.Settings;

    public class IdentitySettingProvider : SettingDefinitionProvider
    {
        public override void Define(ISettingDefinitionContext context)
        {
            context.Add(
                new SettingDefinition(
                    IdentitySettingNames.Password.RequiredLength,
                    6.ToString(),
                    L("DN:Password.RequiredLength"),
                    L("D:Password.RequiredLength"),
                    true),

                new SettingDefinition(
                    IdentitySettingNames.Password.RequiredUniqueChars,
                    1.ToString(),
                    L("DN:Password.RequiredUniqueChars"),
                    L("D:Password.RequiredUniqueChars"),
                    true),

                new SettingDefinition(
                    IdentitySettingNames.Password.RequireNonAlphanumeric,
                    true.ToString(),
                    L("DN:Password.RequireNonAlphanumeric"),
                    L("D:Password.RequireNonAlphanumeric"),
                    true),

                new SettingDefinition(
                    IdentitySettingNames.Password.RequireLowercase,
                    true.ToString(),
                    L("DN:Password.RequireLowercase"),
                    L("D:Password.RequireLowercase"),
                    true),

                new SettingDefinition(
                    IdentitySettingNames.Password.RequireUppercase,
                    true.ToString(),
                    L("DN:Password.RequireUppercase"),
                    L("D:Password.RequireUppercase"),
                    true),

                new SettingDefinition(
                    IdentitySettingNames.Password.RequireDigit,
                    true.ToString(),
                    L("DN:Password.RequireDigit"),
                    L("D:Password.RequireDigit"),
                    true),

                new SettingDefinition(
                    IdentitySettingNames.Lockout.AllowedForNewUsers,
                    true.ToString(),
                    L("DN:Lockout.AllowedForNewUsers"),
                    L("D:Lockout.AllowedForNewUsers"),
                    true),

                new SettingDefinition(
                    IdentitySettingNames.Lockout.LockoutDuration,
                    (5 * 60).ToString(),
                    L("DN:Lockout.LockoutDuration"),
                    L("D:Lockout.LockoutDuration"),
                    true),

                new SettingDefinition(
                    IdentitySettingNames.Lockout.MaxFailedAccessAttempts,
                    5.ToString(),
                    L("DN:Lockout.MaxFailedAccessAttempts"),
                    L("D:Lockout.MaxFailedAccessAttempts"),
                    true),

                new SettingDefinition(
                    IdentitySettingNames.SignIn.RequireConfirmedEmail,
                    false.ToString(),
                    L("DN:SignIn.RequireConfirmedEmail"),
                    L("D:SignIn.RequireConfirmedEmail"),
                    true),

                new SettingDefinition(
                    IdentitySettingNames.User.IsUserNameUpdateEnabled,
                    true.ToString(),
                    L("DN:User.IsUserNameUpdateEnabled"),
                    L("D:User.IsUserNameUpdateEnabled"),
                    true),

                new SettingDefinition(
                    IdentitySettingNames.User.IsEmailUpdateEnabled,
                    true.ToString(),
                    L("DN:User.IsEmailUpdateEnabled"),
                    L("D:User.IsEmailUpdateEnabled"),
                    true)
            );
        }

        private static LocalizableString L(string name)
        {
            return LocalizableString.Create<IdentityLocalResource>(name);
        }
    }
}
